package cn.wolfcode.luowowo.acticle.query;

import cn.wolfcode.luowowo.common.query.QueryObject;
import cn.wolfcode.luowowo.common.util.DateUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.domain.Sort;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.util.StringUtils;

import java.text.SimpleDateFormat;
import java.util.Date;

@Setter
@Getter
public class FlightScheduledQuery extends QueryObject {

    private String orgCity;
    private String dstCity;
    private Date endDate;
    private String orderType = "-1"; // 排序类型


    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    private Date deptTime;

    public Date getEndDate(){
        return DateUtil.getEndDate(this.deptTime);
    }



    public String getOrderBy(){
        if(this.orderType.equals("price-down")){
            return "price desc";
        }else if(this.orderType.equals("price-up")){
            return "price asc";
        }else if(this.orderType.equals("airline-up")){
            return "dep_time asc";
        }else if(this.orderType.equals("airline-down")){
            return "dep_time desc";
        }else if(this.orderType.equals("arr-up")){
            return "arr_time asc";
        }else if(this.orderType.equals("arr-down")){
            return "arr_time desc";
        }else{
            return "airline_name";
        }
    }
}
